// 新建商店列表
$(function () {
    $("input[name=status]").click(function () {
        if($(this).val() == 1){
            $("#businessList").css('display','none');
        }else{
            $("#businessList").css('display','block');
        }
    })
})

// 打开选择商户的页面
function selectBusiness() {
    var title = "商户列表";
    var url = $.util.getRootPath() + '/page/operatorManager/billManager/businessList.html';
    //url = id ? url + '?id=2&typeId=' + typeId : url;
    var dialog = $.easyui.showDialog({
        iconCls:"",
        title: title,
        width: 800,
        height: 500,
        maximizable: true,
        href: url,
        topMost: true,
        saveButtonText: '保存',
        onSave: function () {
            addStores(dialog);
        }
    });
}

// 从商家列表添加商家
function addStores(dialog) {
    var selections = $("#BusinessListTable").datagrid('getChecked');
    if(selections.length == 0){
        $.messager.alert('警告','未选择任何一条商店信息');
    }else{
        var ids = "";
        for(var i = 0; i < selections.length;i++){
            if(i == selections.length-1){
                ids += selections[i].id;
            }else{
                ids += selections[i].id + "_";
            }
        }
        $("#storeIds").val(ids);
        $("#storeIdList").val("已经选择了"+selections.length+"个商户");
        dialog.dialog('close');
    }
}